
using System;
using LastFMGenNHibernate.EN.LastFM;
using LastFMGen_LastFMWCF.DTO.LastFM;

namespace LastFMGen_LastFMWCF.AdaptersEN.LastFM
{
        public class GrupoDTOENAdapter {
        public static GrupoEN Convert (GrupoDTO dto)
        {
                GrupoEN newinstance = null;

                try
                {
                        if (dto != null) {
                                newinstance = new GrupoEN ();



                                newinstance.NombreGrupo = dto.NombreGrupo;
                                if (dto.Artista_oid != null) {
                                        newinstance.Artista = new System.Collections.Generic.List<LastFMGenNHibernate.EN.LastFM.ArtistaEN>();
                                        foreach (LastFMGen_LastFMWCF.DTO.LastFM.ArtistaDTO entry in dto.Artista_oid) {
                                                newinstance.Artista.Add (LastFM.ArtistaDTOENAdapter.Convert (entry));
                                        }
                                }
                                if (dto.Album_oid != null) {
                                        LastFMGenNHibernate.CAD.LastFM.IAlbumCAD albumCAD = new LastFMGenNHibernate.CAD.LastFM.AlbumCAD ();

                                        newinstance.Album = new System.Collections.Generic.List<LastFMGenNHibernate.EN.LastFM.AlbumEN>();
                                        foreach (int entry in dto.Album_oid) {
                                                newinstance.Album.Add (albumCAD.ReadOIDDefault (entry));
                                        }
                                }
                        }
                }
                catch (Exception ex)
                {
                        throw ex;
                }
                return newinstance;
        }
        }
}
